
package com.wang.cloud.common.mysql.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;

/**
 * MyBatis相关配置
 *
 * @author wangye
 * @date 2019/4/8
 */
public class MyBatisConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
        // 设置 单页分页条数限制
        paginationInnerInterceptor.setMaxLimit(500L);
        // 设置超过总页数后是否返回最后一页数据
        paginationInnerInterceptor.setOverflow(false);
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //将插件放入MybatisPlusInterceptor中才能生效
        interceptor.addInnerInterceptor(paginationInnerInterceptor);
        return interceptor;
    }
}